$(function() {
	$( "#start_date" ).datepicker({
	  dateFormat:'dd/mm/yy',
	  showAnim:'slide',
	  onClose: function( selectedDate ) {
		$( "#end_date" ).datepicker( "option", "minDate", selectedDate );
	  }
	});
	$( "#end_date" ).datepicker({
	  dateFormat:'dd/mm/yy',
	  showAnim:'slide',
	  onClose: function( selectedDate ) {
		$( "#start_date" ).datepicker( "option", "maxDate", selectedDate );
	  }
	});

	$.ajax({
		url: base_url+"/index.php/home/home/area",
		dataType: "json",
		success: function(data) {
			for (var i=0; i<data.length; i++) {
				var res = data[i];
				$('#area').append('<option value='+res.id_provinsi+'>'+res.name_prov+'</option>');
			}
		}
	});

	$("#area").change(function(){
		$.ajax({
			url: base_url+"/index.php/home/home/region",
			dataType: "json",
			data : {
				id : $('#area').val()
			},
			success: function(data) {
				for (var i=0; i<data.length; i++) {
					var res = data[i];
					$('#region').append('<option value='+res.id_kab+'>'+res.name_kab+'</option>');
				}
			}
		});
	});

	$("#region").change(function(){
		$.ajax({
			url: base_url+"/index.php/home/home/course",
			dataType: "json",
			data : {
				id : $('#region').val()
			},
			success: function(data) {
				for (var i=0; i<data.length; i++) {
					var res = data[i];
					$('#course').append('<option value='+res.id_golf+'>'+res.name+'</option>');
				}
			}
		});
	});
});